﻿#ifndef ROBOTACT_H
#define ROBOTACT_H

#include <QMainWindow>
#include <kinectcal.h>
#include "kinectcal.h"
#include <QtNetwork/QUdpSocket>
#include <QTimer>
#include <QTextCodec>
#include <QGridLayout>
#include <QLineEdit>
#include <QLabel>
#include <QFile>
#include <QDir>
#include <QCheckBox>
#include <QDateTime>
#include <QTextEdit>
#include <QFileDialog>
#include <QInputDialog>
#include <QMessageBox>
#include "glwidget.h"

namespace Ui {
class RobotAct;
}

class RobotAct : public QMainWindow
{
    Q_OBJECT

public:
    explicit RobotAct(QWidget *parent = 0);
    ~RobotAct();

private slots:
    void kinectOpenOrClose();
    void kinectDataSave();
    void kinectView();
    void kinectEnable3D();
    void robotisLinkOrUnlink();
    void robotisUdpRecv();
    void robotisReadJoins();
    void robotisSaveJoins();
    void robotisSendJoins();
    void robotisTimeSend();
    void robotisFileOpen();
    void robotisFileSend();
    void robotisCmdSend();
    void robotisOrder1();
    void robotisOrder2();
    void robotisOrder3();
    void robotisOrder4();
    void robotisOrder5();
    void statusInfoTimerUpdate();
    void statusDateTimerUpdate();

private:
    void robotisInit();

    Ui::RobotAct *ui;
    kinectCal* Kinect;

    const QString jointName[22]={"SHOULDER-RIGHT","SHOULDER-LEFT","ARM-RIGHT","ARM-LEFT","ELBOW-RGIHT","ELBOW-LEFT",
                                 "BUTTOCK-RIGHT","BUTTOCK-LEFT","HIP-RIGHT","HIP-LEFT",
                                 "THIGH-RIGHT","THIGH-LEFT", "KNEE-RIGHT","KNEE-LEFT",
                                 "ANKEL-RIGHT","ANKEL-LEFT","FOOT-RIGHT","FOOT-LEFT","NECK","HEAD","PARA1","PARA2"};

    //const QString jointName[22]={"右肩","左肩","右臂","左臂","右肘","左肘","右臀","左臀","右胯","左胯",
    //                             "右腿","左腿", "右膝","左膝","右足","左足","右掌","左掌","颈部","头部","滚转","俯仰"};

    bool udpStatus;
    QUdpSocket *udpSocketRobotRecv;
    QUdpSocket *udpSocketRobotSend;
    QHostAddress udpIPRobot;
    int udpPortRobotRecv;
    int udpPortRobotSend;

    QTimer timerSend;

    QTimer statusInfoTimer;
    QTimer statusDateTimer;
    QLabel statusInfo;
    QLabel statusDate;
    //widget
    GLWidget *glWidget;
    QVBoxLayout *vboxLayoutGl;
    float robotisAngle[20];
    QVector3D xyzView;
    QTimer viewTimer;

    QWidget *widgetSend;
    QGridLayout *gridLayoutSend;
    QLabel *labelSend;
    QLineEdit *lineEditSend;
    QCheckBox *checkBoxSend;

    QWidget *widgetRead;
    QGridLayout *gridLayoutRead;
    QLabel *labelRead;
    QLineEdit *lineEditRead;

    QFile *kinectFile;
    QTextStream *kinectTextStream;
    QFile *robotFile;
    QTextStream *robotTextStream;
};

#endif // ROBOTACT_H
